package net.biancheng.bean;

import lombok.Data;
import net.biancheng.common.core.BaseEntity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Transient;

/**
 * @author: lb
 * @date: 2023/8/1 10:47
 * @desc: 角色
 **/
@Data
@Entity
@org.hibernate.annotations.Table(appliesTo = "sys_role", comment = "角色信息表")
public class SysRole extends BaseEntity {

    @Column(name = "role_name", columnDefinition = "varchar(30) comment '角色名称'")
    private String roleName;//角色名称

    @Column(name = "role_key", columnDefinition = "varchar(20) comment '角色标识'")
    private String roleKey;//角色标识，如 @ss.hasRole('admin')

    @Column(name = "order_num", columnDefinition = "int(10) comment '显示顺序'")
    private Integer orderNum;//显示顺序

    @Column(name = "is_outside", columnDefinition = "char(1) comment '是否外部可访问 Y-是 N-否'")
    private String isOutside;//是否外部可访问 Y-是 N-否

    @Column(name = "status", columnDefinition = "char(1) comment '状态 （0启用 1禁用）'")
    private String status;//状态 0-启用 1-禁用


    @Transient
    private Long[] menuIds;//菜单组，前端传值回显

    //判断角色是否是管理员
    public boolean isAdmin()
    {
        return isAdmin(this.getId());
    }

    public static boolean isAdmin(Long roleId)
    {
        return roleId != null && 1L == roleId;
    }

}
